<template>
  <div class="order">
      <div class="toDay"><span class="back"></span>{{title}}</div>
      <div class="list">
        <ul>

          <li v-for="item in date">
            <p class="number">{{item.order_no}} <span>{{item.created_at}}</span></p>
            <p class="title">{{item.sport_match.match_name}}</p>
            <p class="txtle">{{item.set_content|title}} ({{item.set_content|txtle}})</p>
            <p class="price">{{item.buy_amount}} 积分 ({{item.set_odds}})</p>
            <div class="numBox">
              <p class="txtle">半场比分 {{item.sport_match.home_crop_half_score}} : {{item.sport_match.away_crop_half_score}}</p>
              <p class="txtle">全场比分 {{item.sport_match.home_crop_score}} : {{item.sport_match.away_crop_score}}</p>
            </div>
            
            <p class="end" v-if="item.sport_match.match_status!=3">{{item.is_handle|stateFil}}</p>
            <p class="end" v-if="item.sport_match.match_status==3">{{item.is_winner|showFil}}</p>
          </li>
        </ul>
      </div>
  </div>
</template>

<script>
import {Get,Post,Put,Del} from '@/api/index.js'


export default {
  name: 'register',
  data () {
    return {
      title:'订单列表',
      id:'',//用户id
      date:'',
      team:'',
      titleName:''
    }
  },
  filters:{
      filte(e){
          let time=e.substring(10,16)
          return time
      },
      stateFil(e){
        if(e==1){
          return '未结算'
        }else{
          return '已结算'
        }
      },
      title(e){
        let title
        let date=JSON.parse(e)
        if(date.total_score_max!=undefined){
          title="总分大于"
        }else if(date.total_score_min!=undefined){
          title="总分小于"
        }else if(date.home_let_point!=undefined){
          title="主队全场"
        }else if(date.home_half_let_point!=undefined){
          title="主队半场"
        }else if(date.away_let_point!=undefined){
          title="客队全场"
        }else if(date.away_half_let_point!=undefined){
          title="客队半场"
        }
        return title
      },
      txtle(e){
        let title
        let date=JSON.parse(e)
        if(date.total_score_max!=undefined){
          title=date.total_score_max
        }else if(date.total_score_min!=undefined){
          title=date.total_score_min
        }else if(date.home_let_point!=undefined){
          title=date.home_let_point
        }else if(date.home_half_let_point!=undefined){
          title=date.home_half_let_point
        }else if(date.away_let_point!=undefined){
          title=date.away_let_point
        }else if(date.away_half_let_point!=undefined){
          title=date.away_half_let_point
        }
        return title
      },
      showFil(e){
        if(e==1){
          return '输'
        }else{
          return '赢'
        }
      }
  },
  mounted(){
    
    this.getMe()
  },
  methods:{
    async getMe(){
      let reg=await Get('/users/me',this.$store.state.token)
      this.id=reg.data.id
      this.getDate()
    },
    
    async getDate(){
      let reg=await Get('/sport/'+this.id+'/order?_include=user,sport_match_set,sport_match',this.$store.state.token)
      console.log(reg)
      this.date=reg.data
      this.team=reg.data.set_content
      //this.titleName=reg.data.sport_match.match_name
    }
  }
}
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>

</style>
